package com.eliza.base.views.device.nfc

import android.nfc.NfcAdapter
import android.os.Build
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.modifier.modifierLocalConsumer
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.eliza.library.device.nfc.NFCTools

@Composable
fun DeviceNFCScreen(it: NavController) {
    val context = LocalContext.current

    val nfcTools = NFCTools(context)
    val nfcAdapter: NfcAdapter = nfcTools.adapter
    Column {
        Text(text = "DeviceNFCScreen:support:${nfcTools.isSupport()}")
        if (nfcTools.isSupport()) {
            showState(nfcAdapter)
        }
    }
}

@Composable
private fun showState(adapter: NfcAdapter) {
    Column(modifier = Modifier.padding(10.dp)) {
        Text(text = "support ${true}")
        Text(text = "support ${adapter.isEnabled}")
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            Text(text = "isSecureNfcEnabled ${adapter.isSecureNfcEnabled}")
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            Text(text = "isSecureNfcSupported ${adapter.isSecureNfcSupported}")
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
            Text(text = "nfcAntennaInfo ${adapter.nfcAntennaInfo}")
        }
    }
}

@Composable
private fun startNfc(adapter: NfcAdapter) {

}